home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Win 50 Game+ Vol. 7 (Japan)
/
Win 50 Game+ Vol. 7 (Japan).7z
/
Win 50 Game+ Vol. 7 (Japan).bin
/
games
/
sheep11
/
sh11src.lzh
/
MGMAIN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-05-30
|
7KB
|
254 lines
unit Mgmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, Menus, about;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Game1: TMenuItem;
New1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
Options1: TMenuItem;
Speed1: TMenuItem;
Slow1: TMenuItem;
Mid1: TMenuItem;
Fast1: TMenuItem;
Veryfast1: TMenuItem;
Sheep1: TMenuItem;
N20sheep1: TMenuItem;
N30sheep1: TMenuItem;
N50sheep1: TMenuItem;
N100sheep1: TMenuItem;
Timer2: TMenuItem;
N60sec1: TMenuItem;
N120sec1: TMenuItem;
N180sec1: TMenuItem;
N300sec1: TMenuItem;
Help1: TMenuItem;
Index1: TMenuItem;
About1: TMenuItem;
Score1: TMenuItem;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure New1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure speedClick(Sender: TObject);
procedure sheepClick(Sender: TObject);
procedure timeClick(Sender: TObject);
procedure Index1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private ÉΘî╛ }
public
{ Public ÉΘî╛ }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
const bmax = 100;
showt = 19 * 21;
minsize = 200;
backc = clgreen;
ballc1 = clwhite;
ballc2 = clyellow;
specialc = clred;
type Tball = record
x, y, xx, yy, abxx, abyy : real;
ix, iy : integer;
shape : Trect;
end;
var ball : array[1..bmax] of Tball;
fullrect : Trect;
balls : byte;
l, counter, time, mx, my, scx, scy, cx, cy, rate : integer;
score, best, max, sp, r1, r2 : real;
procedure TForm1.FormCreate(Sender: TObject);
var i, j : integer;
begin
randomize;
balls := 30;
rate := 5;
time := 2299;
max := 78.0;
formresize(sender);
new1click(sender);
end;
procedure TForm1.New1Click(Sender: TObject);
var i : integer;
begin
best := 0;
counter := time;
for i := 1 to bmax do with ball[i] do begin
x := random(scx-40)+20;
y := random(scy-40)+20;
ix := round(x);
iy := round(y);
xx := (random * 2 - 1) * sp;
yy := (random * 2 - 1) * sp;
abxx := abs(xx);
abyy := abs(yy);
end;
canvas.brush.color := backc;
canvas.fillrect(fullrect);
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
application.terminate;
end;
procedure TForm1.speedClick(Sender: TObject);
begin
slow1.checked := false;
mid1.checked := false;
fast1.checked := false;
veryfast1.checked := false;
(sender as Tmenuitem).checked := true;
rate := (sender as Tmenuitem).tag;
sp := (scx + scy) * rate / 8000;
end;
procedure TForm1.sheepClick(Sender: TObject);
begin
N20sheep1.checked := false;
N30sheep1.checked := false;
N50sheep1.checked := false;
N100sheep1.checked := false;
(sender as Tmenuitem).checked := true;
balls := (sender as Tmenuitem).tag;
max := 2.0 * balls + 18;
new1click(sender);
end;
procedure TForm1.timeClick(Sender: TObject);
begin
N60sec1.checked := false;
N120sec1.checked := false;
N180sec1.checked := false;
N300sec1.checked := false;
(sender as Tmenuitem).checked := true;
time := (sender as Tmenuitem).tag;
new1click(sender);
end;
procedure TForm1.Index1Click(Sender: TObject);
begin
application.HelpJump('HID_N0001');
end;
procedure TForm1.About1Click(Sender: TObject);
begin
aboutbox.showmodal;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
for l := 1 to balls do with ball[l] do begin
x := x + xx;
y := y + yy;
ix := round(x);
iy := round(y);
r1 := 110 * sp / ((x-mx)*(x-mx)+(y-my)*(y-my)+0.1);
r2 := abs(x-mx) + abs(y-my);
xx := xx + r1 * (x-mx) / r2;
yy := yy + r1 * (y-my) / r2;
abxx := abs(xx);
abyy := abs(yy);
if abxx > sp then xx := xx / abxx * sp;
if abyy > sp then yy := yy / abyy * sp;
if ix < 20 then xx := abxx else if ix > scx-24 then xx := -abxx;
if iy < 20 then yy := abyy else if iy > scy-24 then yy := -abyy;
end;
with ball[1] do begin
canvas.brush.color := backc;
canvas.fillrect(shape);
shape := rect(ix,iy,ix+4,iy+4);
if counter >= showt then canvas.brush.color := ballc1
else canvas.brush.color := specialc;
canvas.fillrect(shape);
score := (abs(ix/cx-1) + abs(iy/cy-1)) * 10;
end;
for l := 2 to balls do with ball[l] do begin
canvas.brush.color := backc;
canvas.fillrect(shape);
shape := rect(ix,iy,ix+4,iy+4);
if odd(l) then canvas.brush.color := ballc1
else canvas.brush.color := ballc2;
canvas.fillrect(shape);
score := score + abs(ix/cx-1) + abs(iy/cy-1);
end;
score := 100 - score / max * 200;
if best < score then best := score;
dec(counter);
score1.caption := inttostr(round(score)) + '/' + inttostr(round(best))
+ ' T:' + inttostr(counter div 19);
if counter = 0 then begin
timer1.enabled := false;
aboutbox.comment.caption := 'Your score is ' + inttostr(round(best));
aboutbox.showmodal;
aboutbox.comment.caption := '';
new1click(sender);
timer1.enabled := true;
end;
end;
procedure TForm1.FormResize(Sender: TObject);
var i : integer;
begin
if clientwidth < minsize then clientwidth := minsize;
if clientheight < minsize then clientheight := minsize;
if scx > 0 then r1 := clientwidth / scx;
if scy > 0 then r2 := clientheight / scy;
scx := clientwidth;
scy := clientheight;
cx := scx div 2 - 1;
cy := scy div 2 - 1;
canvas.brush.color := backc;
fullrect := rect(0,0,scx,scy);
canvas.fillrect(fullrect);
for i := 1 to balls do with ball[i] do begin
x := x * r1;
y := y * r2;
if x < 20 then x := 20 else if x > scx-24 then x := scx - 24;
if y < 20 then y := 20 else if y > scy-24 then y := scy - 24;
ix := round(x);
iy := round(y);
xx := xx * r1;
yy := yy * r2;
abxx := abxx * r1;
abyy := abyy * r2;
if odd(l) then canvas.brush.color := ballc1
else canvas.brush.color := ballc2;
shape := rect(ix,iy,ix+4,iy+4);
canvas.fillrect(shape);
end;
sp := (scx + scy) * rate / 8000;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
mx := x;
my := y;
end;
end.